<!DOCTYPE html>
<html lang="en">
<head>
    <title>微信分享管理</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/dist/plugins/select2/select2.min.css">
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=e9c5bb62">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=66b457d6">
    <style type="text/css">
        .leftFilter {
            float: left;
            text-align: left;
            margin-right: 5px;
        }

        .table input {
            width: 100%;
            border: 0px;
        }

        a {
            cursor: pointer;
        }
        .content {
            padding: 8px 8px 0 8px;
        }
    </style>
</head>
<body>
<section class="content" id="list">
    <div style="text-align:right;padding-bottom: 10px;">
        <div class="leftFilter">
            <select v-model="companyId" class="form-control select2 companySelect"
                    style="width: 150px; float: left" @change="companyChange($event)">
                <option v-for="option in listCompany" :value="option.id">
                    {{option.name}}
                </option>
            </select>
            <input type="text" @focus="showDatePicker($event)" v-model="time"
                   style="float: left; margin-left: 10px; height: 33px;">
            <input type="button" value="生成需转发链接" @click="saveTodayWechatShare()"
                   class="btn oaBtn btn-sm "
                   style="margin-left: 10px; margin-top: 5px;">
        </div>
    </div>
    <div class="box-body no-padding" style="margin-top: 10px;">
        <table class="table table-bordered">
            <thead>
            <tr>
                <th style="width:16%;" class="tableTitle">名称</th>
                <th style="width:22%;" class="tableTitle">链接</th>
                <th style="width:22%;" class="tableTitle">图片链接</th>
                <th style="width:10%;" class="tableTitle">操作人</th>
                <th style="width:10%;" class="tableTitle">日期</th>
                <th style="width:5%;" class="tableTitle">备注</th>
                <th style="width:5%;" class="tableTitle">转发次数</th>
                <th style="width:120px;" class="tableTitle">操作</th>
            </tr>
            </thead>
            <tr v-for="(item,i) in list">
                <td>
                    <input type="hidden" v-model="item.id"/>
                    <input type="hidden" v-model="item.companyId"/>
                    <input type="text" v-model="item.name"/>
                </td>
                <td>
                    <input type="text" v-model="item.linkUrl"/>
                </td>
                <td>
                    <input type="text" v-model="item.imageUrl"/>
                </td>
                <td>
                    <input type="hidden" v-model="item.createUserId"/>
                    {{item.createUserName}}
                </td>
                <td>
                    <input type="hidden" v-model="item.shareDate"/>
                    {{item.shareDate}}
                </td>
                <td>
                    <input type="text" v-model="item.remark"/>
                </td>
                <td><input type="text" v-model="item.forwardNumber"/></td>
                <td>
                    <a @click="save(item)">保存</a>&nbsp;&nbsp;
                    <a @click="detail(item.linkUrl)" v-if="item.id!=''">查看</a>&nbsp;&nbsp;
                    <a @click="delById(item.id)" v-if="item.id!=''">清空</a>
                </td>
            </tr>
        </table>
    </div>
</section>
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=7e54a132"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=63aed32f"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">

    var app = new Vue({
        el: '#list',
        data: {
            list: [],
            listCompany: [],
            time: "",
            currentUserId: getCurrentUser().id,
            currentUserName: getCurrentUser().name,
            companyId: getCurrentUser().companyId
        },
        methods: {
            showDatePicker: function (e) {
                var that = this;
                WdatePicker({
                    onpicked: function (dp) {
                        that.time = dp.cal.getNewDateStr();
                        that.getList();
                        return true;
                    },
                    dateFmt: 'yyyy-MM-dd'
                });
                $(e.target).blur();
            },
            save: function (item) {
                var that = this;
                item.imageUrl = item.imageUrl.replace(/\s+/g,'');
                $.wyui.postMethod(urlConfig.system.wechatShare.save, item, function (data) {
                    that.getList();
                });
            },
            getList: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.system.wechatShare.getWechatShare, {
                    shareDate: that.time,
                    userId: getCurrentUser().id,
                    companyId: that.companyId
                }, function (data) {
                    that.list = data;
                    var count = that.list.length;
                    if (count < 10) {
                        for (var i = 0; i < 10 - count; i++) {
                            var o = new Object();
                            o.id = '';
                            o.name = '';
                            o.linkUrl = '';
                            o.imageUrl = ''
                            o.createUserId = that.currentUserId;
                            o.createUserName = that.currentUserName;
                            o.companyId = that.companyId;
                            o.shareDate = that.time;
                            o.forwardNumber = '1';
                            that.list.push(o);
                        }
                    }


                })
            },
            detail: function (linkUrl) {
                $.dialog({
                    content: 'url:detail.html?linkUrl=' + linkUrl + "&t=" + new Date(),
                    title: '微信分享',
                    width: 400,
                    height: 700,
                    max: false,
                    min: false,
                    lock: true
                });
            },
            delById: function (id) {
                var that = this;
                $.wyui.postMethod(urlConfig.system.wechatShare.delById, {
                    id: id
                }, function (data) {
                    that.getList();
                })
            },
            companyChange: function (e) {
                var that = this;
                that.companyId = e.target.value;
                that.getList();
            },
            saveTodayWechatShare: function (item) {
                var that = this;
                $.wyui.postMethod(urlConfig.system.wechatShare.saveTodayWechatShare, {
                    userId: getCurrentUser().id,
                    companyId: that.companyId,
                    shareDate: that.time
                }, function (data) {
                    that.getList();
                })
            }
        },
        mounted: function () {
            var that = this;
            $.wyui.postMethod(urlConfig.system.company.getCompanyList, {}, function (data) {
                that.listCompany = data;
            });
            //今天的日期
            var today = new Date().Format("yyyy-MM-dd");
            that.time = today;
            that.getList();
        }
    });


</script>

</body>
</html>